﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Win32;

namespace HA.ModFlow.Controls.Windows
{
    /// <summary>
    /// winExportBitmapForm3D.xaml 的交互逻辑
    /// </summary>
    public partial class winExportBitmapForm3D : Window
    {
        public winExportBitmapForm3D()
        {
            InitializeComponent();
            this.DataContext = this;
        }

        HAVTKPack.SaveScreenSetup _screenSetup;

        public HAVTKPack.SaveScreenSetup ScreenSetup
        {
            get { return _screenSetup; }
        }

        int _resolution = 1;

        public int Resolution
        {
            get { return _resolution; }
            set
            {
                if (value > 0)
                    _resolution = value;
            }
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "保存图像";
            sfd.CheckPathExists = true;
            sfd.OverwritePrompt = true;
            sfd.Filter = "Bitmap File(*.bmp)|*.bmp|" + "Pnm File(*.pnm)|*.pnm|" + "JPEG File(*.jpg)|*.jpg|" + "PNG File(*.png)|*.png";
            if (sfd.ShowDialog().Value)
            {
                string filename = sfd.FileName;
                string format = filename.Remove(0, filename.Length - 3);
                switch (format)
                {
                    case "bmp":
                        this._screenSetup = new HAVTKPack.SaveScreenSetup(HAVTKPack.SaveScreenType.BMP, sfd.FileName, _resolution);
                        break;
                    case "jpg":
                        this._screenSetup = new HAVTKPack.SaveScreenSetup(HAVTKPack.SaveScreenType.JEPG, sfd.FileName, _resolution);
                        break;
                    case "pnm":
                        this._screenSetup = new HAVTKPack.SaveScreenSetup(HAVTKPack.SaveScreenType.PNM, sfd.FileName, _resolution);
                        break;
                    case "png":
                        this._screenSetup = new HAVTKPack.SaveScreenSetup(HAVTKPack.SaveScreenType.PNG, sfd.FileName, _resolution);
                        break;
                    default:
                        break;

                }
                this.DialogResult = true;
                this.Close();
            }
        }
    }
}
